﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ORMAC.Paterns
{
    /// <summary>
    /// class to represent singleton pattern
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Singleton<T> where T:new() 
    {
        private static object lockObject = new object();
        private static T instance;
        public static T Instance
        {
            get
            {
                    if (instance == null)
                    {
                        lock (lockObject)
                        {
                            if(instance==null)
                                instance = new T();
                        }
                    }
                return instance;
            }
        }
    }
}
